package com.nineshadow.games.core.step;

import cn.stylefeng.guns.modular.system.model.Room;
import com.nineshadow.games.core.GameRoom;
import com.nineshadow.games.interfaces.IStep;
import com.nineshadow.games.launch.HallServer;
import com.nineshadow.games.util.MyUtils;
import lombok.extern.slf4j.Slf4j;

import java.util.Objects;

@Slf4j
public class Step2Over implements IStep {
    private static final int sleepTime = 1;


    @Override
    public void start(GameRoom room) {
        //推送游戏结束，并延迟2s结算
        if (!room.isTerminated()) {
            log.info("游戏结算：{}", room.SubscribeTab);
            HallServer.publishService.publish(room.SubscribeTab,room.users.get(0).getId(), MyUtils.putMsg("timeOver"));
            HallServer.publishService.publish(room.SubscribeTab,room.users.get(1).getId(), MyUtils.putMsg("timeOver"));
            MyUtils.sleepSomeMillis(200);
            //结算
            room.gameOver();
        }
        room.terminate();
    }
}
